package com.javase01;

public class ArryTest {
    public static void main(String[] args) {
        MyTools myTools = new MyTools();
        int[] arr = {13, 3, 16, 79, 46};
        myTools.Arr(arr);
        for (int i = 0 ; i < arr.length ; i++) {
            System.out.print(arr[i] + " ");
        }
    }
}

class MyTools {
    //冒泡排序实现
    public void Arr(int[] arr) {
        int temp = 0;
        for (int i = 0 ; i < arr.length - 1 ; i++) {//外层循环为数组长度-1
            for (int j = 0 ; j < arr.length - 1 - i ; j++) {
                if (arr[i] > arr[i + 1]) {
                    temp = arr[i];
                    arr[i] = arr[i + 1];
                    arr[i + 1] = temp;
                }
            }
        }
    }
}
